﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CarHelpDesk.Web.Models.Repositories;
using CarHelpDesk.Web.Models;

namespace CarHelpDesk.Web.Controllers
{
    public class ImageController : Controller
    {
        IImagesRepository repo {get;set;}

        public ImageController()
        {
            repo = new CarHelpDesk.Web.Models.Repositories.LinqRepositories.ImagesRepository();
        }

        public ImageController(IImagesRepository cRepository)
        {
            repo = cRepository;
        }

        public ActionResult Details(int id)
        {
            Image img = repo.GetImageByID(id);

            Response.ContentType = img.ContentType;
 Response.BinaryWrite(img.Data.ToArray());

            return View("Details", img);

        }

        
    }
}
